package com.kerbores.blog.bean;

import java.util.Date;
import java.util.List;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.lang.Times;

/**
 * 文章
 * 
 * @author 贵源 <br>
 *         create at 2014年10月19日
 */
@Table("b_article")
public class Article extends Entity {

	/**
	 * 访问控制级别
	 * 
	 * @author 贵源 <br>
	 *         create at 2014年10月19日
	 */
	public static enum ACL {
		PUBLIC, PRIVATE, ENCRYPTED;
		public String getMsg() {
			switch (this) {
			case ENCRYPTED:
				return "加密文章";
			case PRIVATE:
				return "私有文章";
			default:
				return "公开文章";
			}
		}
	}

	/**
	 * 分类id
	 */
	@Column("catalog_id")
	private int catalogId;
	/**
	 * 作者id
	 */
	@Column("author_id")
	private int authorId;
	@Column("acl")
	private ACL acl = ACL.PUBLIC;
	@Column("url")
	private String url;
	@Column("title")
	private String title;
	@Column("summary")
	private String summary;
	@Column("content")
	@ColDefine(width = 10000)
	private String content;
	@Column("ip")
	private String ip;
	@Column("publish_time")
	private Date publishTime = Times.now();
	@Column("last_edit")
	private Date lastEdit = Times.now();
	@Column("view_count")
	private int viewCount = 0;
	@Column("tag_info")
	private String tagInfo;
	@Column("top")
	private boolean top;
	@One(field = "authorId", key = "id", target = User.class)
	private User author;
	@One(field = "catalogId", key = "id", target = Catalog.class)
	private Catalog catalog;
	

	public int getCatalogId() {
		return catalogId;
	}

	public void setCatalogId(int catalogId) {
		this.catalogId = catalogId;
	}

	public int getAuthorId() {
		return authorId;
	}

	public void setAuthorId(int authorId) {
		this.authorId = authorId;
	}

	public ACL getAcl() {
		return acl;
	}

	public void setAcl(ACL acl) {
		this.acl = acl;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Date getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}

	public Date getLastEdit() {
		return lastEdit;
	}

	public void setLastEdit(Date lastEdit) {
		this.lastEdit = lastEdit;
	}

	public int getViewCount() {
		return viewCount;
	}

	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}

	public String getTagInfo() {
		return tagInfo;
	}

	public void setTagInfo(String tagInfo) {
		this.tagInfo = tagInfo;
	}

	public boolean isTop() {
		return top;
	}

	public void setTop(boolean top) {
		this.top = top;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public Catalog getCatalog() {
		return catalog;
	}

	public void setCatalog(Catalog catalog) {
		this.catalog = catalog;
	}

	public List<Tag> getTags() {
		return tags;
	}

	public void setTags(List<Tag> tags) {
		this.tags = tags;
	}

	private List<Tag> tags;

}
